<?php
if(isset($_POST["join"])){ // add course
		GroupJoin();
	}else if(isset($_POST["withdrawn"])){
		GroupQuit();
	}


function GroupQuit()
	{
		session_start(); 
	if( !$_SESSION["login"])header('Location: error_page.php');
	include("db_util.php");
	putenv("ORACLE_HOME=/usr/local/libexec/oracle/app/oracle/product/11.2.0/client_1");
	$connection=DbConnect();
	date_default_timezone_set('EST');
	$query='delete from stugroup where StudentID=' . $_SESSION["StuID"] . " and GroupID=" . $_GET["GID"];
	$statement = oci_parse($connection, $query);
	oci_execute($statement);
	DbConnectionClose($connection,  $statement);
header('Location: GroupPage.php?GID='.$_GET["GID"]);
	//ocifetch ( $statement ) ;
	}

function GroupJoin()
	{
		session_start(); 
	if( !$_SESSION["login"])header('Location: error_page.php');
	include("db_util.php");
	putenv("ORACLE_HOME=/usr/local/libexec/oracle/app/oracle/product/11.2.0/client_1");
	$connection=DbConnect();
	date_default_timezone_set('EST');
	$query='Insert into stugroup values(' . $_SESSION["StuID"] . "," . $_GET["GID"] . ",'" . date('d-M-y') . "')";
	$statement = oci_parse($connection, $query);
	oci_execute($statement);
	DbConnectionClose($connection,  $statement);
header('Location: GroupPage.php?GID='.$_GET["GID"]);
	//ocifetch ( $statement ) ;
	}
?>
